// Define the turfs to be used in the dungeon.
turf/es/wall
	icon = 'eswall.dmi'
	density = 1
	opacity = 1

turf/es/path
	icon = 'espath.dmi'

turf/es/room
	icon = 'esroom.dmi'

turf/es/door
	icon = 'esdoor.dmi'
	icon_state = "closed"
	density = 1
	opacity = 1
	Click()
		Use(usr)
	proc/Use()
		if (density)
			src.icon_state = "opened"
			src.density = 0
		else
			src.icon_state = "closed"
			src.density = 1

turf/es/stairs
	var
		id			// The id of the dungeon these stairs lead to
		tolevel		// the level of the dungeon.

		turf/_toloc
	icon = 'esstairs.dmi'
	up
		icon_state = "up"
	down
		icon_state = "down"
	DblClick() Use(usr)
	proc/Use(mob/m)
		if(m.loc != src) return
		if(_toloc)
			m.loc = _toloc
			return
		var/es_dungeon/dun = es_dungeonMan.Dungeon(id)
		if(!dun) return
		var/i = dun.Level(tolevel)
		if(!i) i =dun.Generate_Map(src)
		_toloc = locate(x,y,i)
		if(!istype(_toloc, /turf/es/stairs/up))
			for(var/turf/es/stairs/up/t in block(locate(1,1,i), locate(dun.width, dun.height, i)))
				_toloc = t
		m.loc = _toloc

es_dungeon
	FirstDungeon
		// This is used to identify the dungeon in staircases and such.
		id = "FirstDungeon"

		// type definitions to use
		wall_type = /turf/es/wall
		path_type = /turf/es/path
		room_type = /turf/es/room
		door_type = /turf/es/door

		levels = 4 // Total number of levels to generate
		height = 35
		width  = 35
		features = 400